<template>
	<view class="u-page">
		<view v-for="(item, index) in list" :key="index">
			<u-cell customStyle="background:#fff;" @click="goTongji(item)" :isLink="true">
				<view slot="title">
					<text>{{item.title}}</text>
				</view>
				<view slot="value">
					<text v-if="item.status=='normal'" class="tag-info">正常</text>
					<text v-if="item.status=='hidden'" class="tag-danger">禁用</text>
				</view>
			</u-cell>
		</view>
	</view>
</template>

<script>
	import {baseUrl,methods} from '@/utils/methods.js';
	export default {
		data() {
			return {
				list:[],
				endData:false,
				page:1
			}
		},
		onPullDownRefresh() {
			this.pagelist(true);
		},
		onReachBottom(){
			this.pagelist();
		},
		onLoad(e) {
			this.pagelist();
		},
		methods: {
			...methods,
			goTongji:function(item){
				this.$navigateTo('admin/channel/tongji?channel_id='+item.id);
			},
			pagelist:function(pulldown=false){
				if(this.endData){
					this.$msg('已经到底了');
					return;
				}
				this.$get("channel/index/list",{
					page:this.page
				},true).then(res=>{
					if(pulldown){
						uni.stopPullDownRefresh();
					}
					if(res.length<10){
						this.endData=true;
					}
					this.list=this.list.concat(res);	
					this.page++;	
				}).catch(error=>{
					if(error.msg=='没有权限'){
						setTimeout(()=>{
							this.$reLaunch('index/index');
						},1500);
					}
				});		
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #eeeeee;
	}
</style>